package me.zk.practice1.hw;

import java.util.Scanner;

/**
 * @author zhangkai
 * @date 2023/8/11 18:09
 */
public class HWBJJ05 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String s1 = scanner.nextLine();

        String s2 = scanner.nextLine();

        int max = Integer.parseInt(scanner.nextLine());

        //左指针
        int l = 0;
        //右指针
        int r = 0;
        int maxLen = 0;
        //和
        int sum = 0;
        while (r < s1.length()) {
            char c1 = s1.charAt(r);
            char c2 = s2.charAt(r);
            sum += Math.abs(c1-c2);
            if (sum>max) {
                while (sum > max && l<=r) {
                    char c3 = s1.charAt(l);
                    char c4 = s2.charAt(l);
                    sum -= Math.abs(c3-c4);
                    l++;
                }
                maxLen = Math.max(maxLen ,r-l+1);
            }
            r++;
        }
    System.out.println(maxLen);
    }
}
